package com.jt.redis;

import redis.clients.jedis.Jedis;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class IdGeneratorDemo01 {
    public static Long getId(){
        Jedis jedis = JedisDataSource.getConnection();
        Long id = jedis.incr("id");
        jedis.close();
        return id;
    }

    public static void main(String[] args) {
        ExecutorService es= Executors.newFixedThreadPool(3);
        for (int i=1;i<=10;i++){
            es.execute(new Runnable() {
                @Override
                public void run() {
                    System.out.println(Thread.currentThread().getName()+"==>"+getId());
                }
            });
        }
    }
}
